home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / lb09c.zip / TEST.BAS < prev    next >
BASIC Source File  |  1992-02-29  |  1KB  |  50 lines

  1.  
  2.     '
  3.     ' This program accepts a sentence, then determines its
  4.     ' approximate size, after which it breaks the sentence up
  5.     ' into seperate words.
  6.     ' Then ten numbers are asked for, and they are then
  7.     ' bubble-sorted and displayed
  8.     '
  9.  
  10.  
  11.     dim test(20)
  12.  
  13.     input "Type a sentence >"; s$
  14.     print "s$ is more than 20 chars and less then 50"
  15.     print len(s$) > 20 and len(s$) < 50
  16.     length = len(s$)
  17.  
  18.     ' break s$ up, one line per word
  19.     sLen = len(s$)
  20.     for count = 1 to sLen
  21.         c$ = mid$(s$,count,1)
  22.         copy$ = copy$ + c$
  23.         if c$ = " " then copy$ = copy$ + chr$(13)
  24.     next count
  25.     print copy$
  26.  
  27.     ' ask for 10 numbers to sort
  28.     for count = 1 to 10
  29.         print "Give me number "; count; " >";
  30.         input number
  31.         test(count) = number
  32.     next count
  33.  
  34.     ' outer sort loop
  35.     for outerCount = 1 to 10
  36.  
  37.     ' inner sort loop
  38.     for innerCount = 1 to 9
  39.  
  40.     if test(innerCount) > test(innerCount + 1) then s = test(innerCount) : test(innerCount) = test(innerCount + 1) : test(innerCount + 1) = s
  41.  
  42.     next innerCount
  43.     next outerCount
  44.  
  45.     ' view the sorted array
  46.     for count = 1 to 10
  47.         print test(count)
  48.     next count
  49.  
  50.